#ifndef CELLSPACE_H
#define CELLSPACE_H

#include <SFML/System.hpp>

#include <map>
#include "gameobject.h"

class DLL_EXPORT CellSpace
{
	public:

		// Instantiates a new cellspace partition going from 0 to 'max' in both x and y dimension, partitioned by 'step' parts in each dimension
		CellSpace(float max, int step);
		virtual ~CellSpace();

		// Moves obj from its current pos, and update the cell it lives in,
		void MoveObject(GameObject* obj, const int& newPos);

		// Could handle individual cells with different threads even
		void ResolveCollisions();

		int GetCellIndex(float x, float y)
		{
			float cellSize = maxValue/(float)step;
			return (int)(cellSize/x) + step * (int)(cellSize/y);
		}


	private:
		float maxValue;
		int step;

		std::map<sf::Uint32, GameObject*>* ships;
		std::map<sf::Uint32, GameObject*>* planets;
		std::map<sf::Uint32, GameObject*>* bullets;

};

#endif // CELLSPACE_H
